import React from 'react'
import { ReactGhLikeDiff } from 'react-gh-like-diff'
import 'react-gh-like-diff/lib/diff2html.min.css'

export default class DiffProgramModal extends React.Component {

  getContent = program => {
    const {title, startTime, endTime, categroy, introduction, studentLink, isReadOnly, isExpired, available} = program
    return `名称：${title}
开始时间：${startTime}
结束时间：${endTime}
分类：${categroy}
是否打开学生分享链接：${studentLink}
是否打开助教分享链接：${studentLink}
是否打开只读：${isReadOnly}
是否打开过期功能：${isExpired}
是否被删除：${available}
-----------------------description----------------------
${introduction}
`
  }

  render () {
    const {source, diff} = this.props
    return <ReactGhLikeDiff
      past={this.getContent(source)}
      current={this.getContent(diff)}
      options={{
        originalFileName: source.title,
        updatedFileName: diff.title,
        inputFormat: 'diff',
        outputFormat: 'side-by-side',
        showFiles: true,
        matchWordsThreshold: 0.25,
        matchingMaxComparisons: 2500
      }}
    />

  }
}